#pragma once
#ifndef _CONFIG_
#define _CONFIG_
#include <string>
#include <map>

//the path you change to your own config.ini file
#define CONFIG_FILE_PATH "H:/pro_software_workplace/VisualStudio/ParticleFilterLocalization/ParticleFilterLocalization/localization.ini"

#define TRY_START \
	try                \
	{

#define TRY_END                   \
	}                                  \
	catch (std::bad_alloc&) { throw "bad_alloc"; } \
	catch (const char* msg) { cerr<<msg<<endl; } \
	catch (...) { throw ; } 


/*
** the history debug information logcat switch
** that is mean if you turn it on,then all of logcat will print
*/
#define HISTORY_LOGCAT 0 //0=OFF,1=ON

class Config
{
public:
	Config();
	~Config();
	bool ReadConfig(const std::string & filename);
	std::string ReadString(const char* section, const char* item, const char* default_value);
	int ReadInt(const char* section, const char* item, const int& default_value);
	float ReadFloat(const char* section, const char* item, const float& default_value);
private:
	bool IsSpace(char c);
	bool IsCommentChar(char c);
	void Trim(std::string & str);
	bool AnalyseLine(const std::string & line, std::string& section, std::string & key, std::string & value);

private:
	//std::map<std::string, std::string> settings_;
	std::map<std::string, std::map<std::string, std::string> >settings_;
};


#endif // _CONFIG_
